/*
    This is a set of libraries to assist in OpenGl and Other Applications
    Copyright (C) 2008  The Modular Engine Team

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/// \file InputModule.h
/// \brief This file contains the classes for a generic input handler.
/// While this version does NOT capture input, it does assist in reading it.
/// The capturing of input is OS specific so some work has to be done in each.

#ifndef INPUTMODULE_H
#define INPUTMODULE_H

#include "EngineCore.h"

#undef CLASSDECL
#ifdef INPUTMODULE
	#define CLASSDECL __declspec(dllexport)
#else
	#pragma comment( lib, "InputModule.lib" )
	#define CLASSDECL __declspec(dllimport)
#endif



namespace ModularEngine
{
#if WINDOWS
	/// Keys for get key state.
	
	// This is the Windows Version
	enum IK_SPECIALKEYS
	{
		IK_SHIFT = 0x10,
		IK_CONTROL = 0x11,
		IK_MENU = 0x12,
		IK_PAUSE = 0x13,
		IK_CAPITAL = 0x14,
		IK_ESCAPE = 0x1B,
		IK_SPACE = 0x20,
		IK_PRIOR = 0x21,
		IK_NEXT = 0x22,
		IK_END = 0x23,
		IK_HOME = 0x24,
		IK_LEFT = 0x25,
		IK_UP = 0x26,
		IK_RIGHT = 0x27,
		IK_DOWN = 0x28,
		IK_SELECT = 0x29,
		IK_PRINT = 0x30,
		IK_INSERT = 0x2D,
		IK_DELETE = 0x2E,
		IK_F1 = 0x70,
		IK_F2,
		IK_F3,
		IK_F4,
		IK_F5,
		IK_F6,
		IK_F7,
		IK_F8,
		IK_F9,
		IK_F10,
		IK_F11,
		IK_F12,
		IK_NUMPAD0 = 0x60,
		IK_NUMPAD1,
		IK_NUMPAD2,
		IK_NUMPAD3,
		IK_NUMPAD4,
		IK_NUMPAD5,
		IK_NUMPAD6,
		IK_NUMPAD7,
		IK_NUMPAD8,
		IK_NUMPAD9,
		IK_MULTIPLY,
		IK_ADD,
		IK_SEPARATOR,
		IK_SUBTRACT,
		IK_DECIMAL,
		IK_DIVIDE,
		IK_NUMLOCK = 0x90,
		IK_SCROLL = 0x91,

		IK_VOLUME_MUTE = 0xAD,
		IK_VOLUME_DOWN,
		IK_VOLUME_UP

	};
#endif // #if WINDOWS

	/// Handles all input.
	
	/// Allows easy identification of what keys are down, mouse & joystick positions, etc.
	class CLASSDECL InputModule: BASE(InputModule)
	{
	public:
		int nTypeKeys;
		char typeKeys[255];
		
		//int nSysKeys;
		unsigned char keyboardState[255];

		/// Add typing key
		void addKeyTyped( char cKeyTyped );
#if 0
		/// Add system key

		/// While windows identifies a system key as any key 
		/// sequence that starts with ALT, in ModularEngine,
		/// A system key is any key including typed keys.
		void addSysKey( char cKeySys );
#endif

		/// Pass Keyboard State
		void passKeyboardState( unsigned char kState[255] );

		/// Checks if specified key is currently pressed;
		bool isKeyDown( char cKeyDown );

		/// Prepares the module for input
		int initialize();
		/// Flushes all keys out so there is no latency.   
		
		/// Should be one of last functions called from engine loop.
		int run();

	};

}

#endif // #ifndef INPUTMODULE_H
